package com.autotest.glin.common;

import com.alibaba.fastjson.JSON;
import io.restassured.RestAssured;
import io.restassured.response.Response;


import java.util.Map;

public class RunCaseParams {
    public static Response runCase(String bodyString, String methodType) {
        Response response = null;

        Map<String, Object> paramsMap = JSON.parseObject(bodyString).getJSONObject("data");
        if (methodType.toLowerCase().equals("get")){
            response = RestAssured.given().contentType("application/x-www-form-urlencoded;charset=UTF-8").request()
                    .params(paramsMap).get();
            response.then().statusCode(200).log().all();
        }
        return response;
    }

    public static void main(String[] args) {
        String jsonString = "{\"schoolId\":1,\"auditRoleIds\":[1,3,4,5,7,19,20,21,22,23,25,27,28,40,42,45,48,49,54],\"invokePageName\":\"groupPassPage\",\"invokeTabName\":\"\",\"current\":1,\"size\":10,\"operatorName\":\"wangdapeng\",\"operatorEmail\":\"wangdapeng@xdf.cn\",\"isDeptInit\":1,\"deptCode\":\"\",\"projectCode\":\"\",\"managementProjectCode\":\"\",\"gradeCodes\":[],\"subjectCodes\":[],\"quarterCodes\":[],\"productSystemCode\":\"\",\"productLevelCode\":\"\",\"categoryCode\":\"\",\"isSignDeleted\":0,\"keyWord\":\"\",\"deptCodeList\":[\"01\",\"02\",\"03\",\"04\",\"05\",\"06\",\"10\",\"07\",\"09\",\"11\",\"15\",\"16\",\"91\",\"20\",\"21\",\"18\",\"13\",\"88\",\"49\",\"111\",\"47\",\"50\",\"377\",\"51\",\"52\",\"53\",\"54\",\"56\",\"6600\",\"55\",\"12\",\"6100\",\"6101\",\"6102\",\"6103\",\"6104\",\"57\",\"6110\",\"6111\",\"58\",\"0909\",\"19\",\"99\"]}";
        Map<String, Object> jsonMap = JSON.parseObject(jsonString);
        for (Object map : jsonMap.entrySet()) {
            System.out.println(((Map.Entry) map).getKey() + "  " + ((Map.Entry) map).getValue());
        }
    }
}
